package com.mchat.domain;

import lombok.Data;

@Data
public class Result<T> {
    private boolean ok;
    private String msg;
    private  T data;
    public static <T> Result<T> ok(T data){
        return new Result<>(true,"ok",data);
    }
    public static <T> Result<T> ok( ){
        return new Result<>(true,"ok",null);
    }

    public static <T> Result<T> error(boolean ok, String msg) {
        return new Result<>(ok ,msg , null);
    }
    public static <T> Result<T> error(boolean ok, String msg, T data) {
        return new Result<>(ok ,msg , data);
    }
    public static <T> Result<T> error(String msg) {
        return new Result<>(false ,msg , null);
    }


    public Result(boolean ok, String msg, T data) {
        this.ok = ok;
        this.msg = msg;
        this.data = data;
    }
}
